/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Current.Armory;

import Current.Armory.Items.DefenseItems;

import java.io.Serializable;

/**
 * @author tiago
 */
public class DefenseArmory implements Armory, Serializable, Cloneable {

    private DefenseItems weapons;
    private DefenseItems helms;
    private DefenseItems armors;
    private DefenseItems boots;
    private DefenseItems bracers;
    private DefenseItems shields;
    private Integer guards;

    public DefenseArmory(Integer guards, DefenseItems weapons, DefenseItems helms, DefenseItems armors, DefenseItems boots, DefenseItems bracers, DefenseItems shields) {
        this.weapons = weapons;
        this.helms = helms;
        this.armors = armors;
        this.boots = boots;
        this.bracers = bracers;
        this.shields = shields;
        this.guards = guards;
    }

    public DefenseArmory(Integer guards) {
        this.weapons = new DefenseItems(0, 12500, 25);
        this.helms = new DefenseItems(0, 3000, 6);
        this.armors = new DefenseItems(0, 9500, 19);
        this.boots = new DefenseItems(0, 3000, 6);
        this.bracers = new DefenseItems(0, 1500, 3);
        this.shields = new DefenseItems(0, 6000, 12);
        this.guards = guards;
    }

    public DefenseItems getWeapons() {
        return weapons;
    }

    public void setWeapons(DefenseItems weapons) {
        this.weapons = weapons;
    }

    public DefenseItems getHelms() {
        return helms;
    }

    public void setHelms(DefenseItems helms) {
        this.helms = helms;
    }

    public DefenseItems getArmors() {
        return armors;
    }

    public void setArmors(DefenseItems armors) {
        this.armors = armors;
    }

    public DefenseItems getBoots() {
        return boots;
    }

    public void setBoots(DefenseItems boots) {
        this.boots = boots;
    }

    public DefenseItems getBracers() {
        return bracers;
    }

    public void setBracers(DefenseItems bracers) {
        this.bracers = bracers;
    }

    public DefenseItems getShields() {
        return shields;
    }

    public void setShields(DefenseItems shields) {
        this.shields = shields;
    }

    public int getSetDefenseBonus() {
        int aux = 0;

        aux += this.weapons.getDefenseBonus();
        aux += this.helms.getDefenseBonus();
        aux += this.armors.getDefenseBonus();
        aux += this.boots.getDefenseBonus();
        aux += this.bracers.getDefenseBonus();
        aux += this.shields.getDefenseBonus();

        return aux;
    }

    public int getSetCost() {
        int aux = 0;

        aux += this.weapons.getCostToBuy();
        aux += this.helms.getCostToBuy();
        aux += this.armors.getCostToBuy();
        aux += this.boots.getCostToBuy();
        aux += this.bracers.getCostToBuy();
        aux += this.shields.getCostToBuy();

        return aux;
    }

    private int getDefenseFromWeapons() {
        if (this.weapons.getHave() >= guards) {
            return this.weapons.getDefenseBonus() * guards;
        } else {
            return this.weapons.getDefenseBonus() * this.weapons.getHave();
        }
    }

    private int getDefenseFromHelms() {
        if (this.helms.getHave() >= guards) {
            return this.helms.getDefenseBonus() * guards;
        } else {
            return this.helms.getDefenseBonus() * this.helms.getHave();
        }
    }

    private int getDefenseFromArmors() {
        if (this.armors.getHave() >= guards) {
            return this.armors.getDefenseBonus() * guards;
        } else {
            return this.armors.getDefenseBonus() * this.armors.getHave();
        }
    }

    private int getDefenseFromBoots() {
        if (this.boots.getHave() >= guards) {
            return this.boots.getDefenseBonus() * guards;
        } else {
            return this.boots.getDefenseBonus() * this.boots.getHave();
        }
    }

    private int getDefenseFromBracers() {
        if (this.bracers.getHave() >= guards) {
            return this.bracers.getDefenseBonus() * guards;
        } else {
            return this.bracers.getDefenseBonus() * this.bracers.getHave();
        }
    }

    private int getDefenseFromShields() {
        if (this.shields.getHave() >= guards) {
            return this.shields.getDefenseBonus() * guards;
        } else {
            return this.shields.getDefenseBonus() * this.shields.getHave();
        }
    }

    public int getTotalDefenseBonus() {
        int aux = 0;

        aux += getDefenseFromWeapons();
        aux += getDefenseFromHelms();
        aux += getDefenseFromArmors();
        aux += getDefenseFromBoots();
        aux += getDefenseFromBracers();
        aux += getDefenseFromShields();

        return aux;
    }

    public Integer getGuards() {
        return guards;
    }

    public void setGuards(Integer guards) {
        this.guards = guards;
    }


}
